package com.sky.config;

import com.sky.properties.AliOssProperties;
import com.sky.utils.AliOssUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

//用于管理AliOssUtil的配置类，并交给IOC容器管理
@Slf4j
@Configuration
public class OSSConfiguration {

    // 定义一个AliOssUtil的Bean
    @Bean
    public AliOssUtil aliOSSUtil(AliOssProperties aliOSSProperties) {
        // 打印日志信息
        log.info("初始化aliOSSUtil对象");
        // 创建AliOssUtil对象
        AliOssUtil aliOSSUtil = new AliOssUtil(aliOSSProperties.getEndpoint(),
                aliOSSProperties.getAccessKeyId(),
                aliOSSProperties.getAccessKeySecret(),
                aliOSSProperties.getBucketName());
        // 返回AliOssUtil对象
        return aliOSSUtil;
    }
}
